/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controladores;

import entities.EntradaSalidaArticulos;
import entities.VentasDetalle;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceException;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;

/**
 *
 * @author edgar
 */
public class EntradaSalidaArticulosController {

    @PersistenceContext(unitName = "sgal3PU")
    EntityManager em;

    public Boolean crearSalidaArticulosPorVenta(EntradaSalidaArticulos esa) {
        Boolean inserto = false;
        UserTransaction t;
        try {

           // t = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
           // t.begin();
            em.persist(esa);
           // t.commit();
            inserto = true;
        } catch (PersistenceException ex) {
            //t.rollback();
            ex.printStackTrace();
        } /*catch (NamingException ex) {
         * Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
         * }*/ /*catch (NotSupportedException ex) {
          * Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
          * }*//* catch (SystemException ex) {
           * Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
           * } catch (Rollcatch (SystemException ex) {
           * LoggbackException ex) {
           * Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
           * } catch (HeuristicMixedException ex) {
           * Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
           * } catch (HeuristicRollbackException ex) {
           * Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
           * } */catch (SecurityException ex) {
            Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalStateException ex) {
            Logger.getLogger(VentasController.class.getName()).log(Level.SEVERE, null, ex);
        }

        return inserto;
    }
}
